package com.wondream.myframework.app.controller.web;

import com.wondream.myframework.app.domain.LitemallOrder;
import com.wondream.myframework.app.common.interceptor.OperateLog;
import com.wondream.myframework.app.service.LitemallOrderService;
import com.wondream.myframework.app.common.util.ResponseUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 测试服务
 */
@RestController
@RequestMapping("/wx/index")
public class WxIndexController {
    private final Log logger = LogFactory.getLog(WxIndexController.class);

    @Autowired
    LitemallOrderService orderService;

    /**
     * 测试数据
     *
     * @return 测试数据
     */
    @GetMapping("/index")
    @OperateLog
    public Object index() {
        return ResponseUtil.ok("hello world, this is wx service");
    }

    /**
     * 测试双数据库-slave
     *
     * @return 测试双数据库
     */
    @GetMapping("/getOrderTest")
    @OperateLog
    public Object getOrderTest() {
        List<LitemallOrder> litemallOrders = orderService.queryComment(1);
        return ResponseUtil.ok(litemallOrders);
    }

    /**
     * 测试双数据库-master
     *
     * @return 测试双数据库
     */
    @GetMapping("/orderTest")
    @OperateLog
    public Object orderTest() {
        Map<Object, Object> info = orderService.orderInfo(1);
        return ResponseUtil.ok(info);
    }

}